package com.eduadmin.controller;

import com.alibaba.excel.EasyExcel;
import com.eduadmin.entity.TeachInfo;
import com.eduadmin.entity.Team;
import com.eduadmin.listener.TeachInfoDataUploadListener;
import com.eduadmin.listener.TeamDataUploadListener;
import com.eduadmin.service.ITeachInfoService;
import com.eduadmin.service.ITeamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Controller
public class TeamController {
    //构造函数自动装配
    private final ITeamService teamService;
    @Autowired
    public TeamController(ITeamService teamService){
        this.teamService= teamService;
    }
    @RequestMapping(value = "addTeams")
    @ResponseBody
    public String addTeams(MultipartFile teamFile) throws IOException {
        EasyExcel.read(teamFile.getInputStream(), Team.class, new TeamDataUploadListener(teamService)).sheet().doRead();
        return "上传成功";


    }


}
